package com.iotimc.networklibrary.entity;

import android.os.Parcel;
import android.os.Parcelable;


/**
 * Created by david on 2017/4/26.
 *
 * @author  david
 */

public class BaseEntity<E> implements Parcelable {
    private long time;
    private String message;
    private String status;
    private E result;
    //数据总数（分页用到）
    private int recordsTotal;


    public void setRecordsTotal(int recordsTotal) {
        this.recordsTotal = recordsTotal;
    }

    public int getRecordsTotal() {
        return recordsTotal;
    }

    public BaseEntity(){

    }

    protected BaseEntity(Parcel in) {
        time = in.readLong();
        message = in.readString();
        status = in.readString();
    }



    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time = time;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public E getResult() {
        return result;
    }

    public void setResult(E result) {
        this.result = result;
    }

    public boolean isSuccess() {
        return "1".equals(status);
    }


    public static final Creator<BaseEntity> CREATOR = new Creator<BaseEntity>() {
        @Override
        public BaseEntity createFromParcel(Parcel in) {
            return new BaseEntity(in);
        }

        @Override
        public BaseEntity[] newArray(int size) {
            return new BaseEntity[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(time);
        dest.writeString(message);
        dest.writeString(status);
    }
}

